<?php

namespace App\Admin\Renderables;

use App\Admin\Actions\Delete;
use App\Logics\Logic;
use App\Models\AdminUser;
use App\Models\DyBaseInfo;
use App\Models\DyXfzdy;
use App\Models\DzzInfo;
use App\Models\DzzYjdzzInfo;
use App\Models\Role;
use App\Models\SpecialNode;
use App\Models\User;
use App\Policies\Admin\AdminPolicy;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Widgets\Tooltip;

class DzzInfoRenderTable extends LazyRenderable
{
    public function grid(): Grid
    {
        $admin_user = AdminUser::find(Admin::user()->id);
        $sql = isset($this->payload['sql']) ? $this->payload['sql'] : '';
        $builder = Logic::getBaseQuery(DzzInfo::query(), $admin_user, false);
        if($sql){
            $builder->whereRaw($sql);
        }

        $grid = Grid::make($builder, function (Grid $grid) {
            $grid->combine('联系支部情况', ['lx_name', 'lx_hdsl'])->style('text-align: center;');
            $grid->combine('党支部书记信息', ['sj_name', 'sj_sex', 'sj_mz', 'sj_gzgw', 'sj_xlxw', 'sj_zwzc'])->style('text-align: center;');

            $grid->column('zblx','支部类型');
            $grid->column('qssj','本届起始时间');
            $grid->column('rs','支部委员会人数');
            $grid->column('ndkhjg','年度考核结果');
            $grid->column('dyrs','党员人数');
            $grid->column('lx_name','联系教师姓名');
            $grid->column('lx_hdsl','参加活动次数');
            $grid->column('sj_name','姓名');
            $grid->column('sj_sex','性别');
            $grid->column('sj_mz','民族');
            $grid->column('sj_gzgw','职务职称');
            $grid->column('sj_xlxw','学历学位');
            $grid->column('sj_zwzc','职务职称');
            $grid->disableActions();
            $grid->setDialogFormDimensions('700px', '750px');
            $grid->disableCreateButton();
        });
        $grid->disableActions()->disableFilter()->disableCreateButton()->disableRowSelector();
        $grid->paginate(10);
        return $grid;
    }
}